const fs = require("fs");
const { transformFromAstSync } = require("@babel/core");
const parser = require("@babel/parser");
const autoTrackPlugin = require("./plugin/auto-track-plugin")
const path = require('path');

const sourceCode = fs.readFileSync(path.join(__dirname, "./sourceCode.js"), {
  encoding: "utf-8",
});
const ast = parser.parse(sourceCode, {
  sourceType: "unambiguous"
})

const { code } = transformFromAstSync(ast, sourceCode, {
  plugins:[[autoTrackPlugin, {
    // 这个是plugin的options配置。根据plugin自己需求来配置的，因为在plugin里面可以通过options拿到这些配置
    trackerPath: "tracker"
  }]]
})

console.info(code)